﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Renci.iRods.Common;
using System.Collections.ObjectModel;

namespace Renci.iRods.Packets
{
    //#define InxValPair_PI "int isLen; int *inx(isLen); str *svalue[isLen];" 
    [Packet("InxValPair_PI")]
    internal class IndexValuePairPacket : Packet
    {
        private IDictionary<DataObjectAttributes, string> conditions;

        [PacketField("isLen", 0, DataTypes.Int)]
        public int Length { get; set; }

        [PacketField("inx", 1, DataTypes.Int, true)]
        public DataObjectAttributes[] Key { get; set; }

        [PacketField("svalue", 2, DataTypes.String, true)]
        public string[] Value { get; set; }

        public IndexValuePairPacket(IDictionary<DataObjectAttributes, string> conditions)
        {
            if (conditions != null)
            {
                this.Length = conditions.Count;
                this.Key = (from c in conditions select c.Key).ToArray();
                this.Value = (from c in conditions select c.Value).ToArray();
            }
            else
            {
                this.Length = 0;
            }
        }
    }
}
